package system.model.request;

import common.model.enums.BusinessCodeValidEnum;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.util.List;

/**
 * @author 米泽鹏
 * @since 2022-3-12 下午 2:33
 */
@Data
public class SaveBusinessCodeRequest {

	/**
	 * sys_business_code表主键
	 */
	private Long id;

	@NotBlank(message = "业务编码【codeType】不能为空")
	private String codeType;

	@NotBlank(message = "业务编码名称【codeTypeName】不能为空")
	private String codeTypeName;

	/**
	 * 是否有效<br/>
	 * 见{@link BusinessCodeValidEnum}
	 */
	@NotNull(message = "是否启用【valid】不能为空")
	@Min(value = 0, message = "是否启用【valid】取值只能为0或1")
	@Max(value = 1, message = "是否启用【valid】取值只能为0或1")
	private Integer valid;

	@Valid
	@NotEmpty(message = "详情列表（detailList）不能为空")
	private List<SysBusinessCodeDetailVo> detailList;

	@Data
	public static class SysBusinessCodeDetailVo {

		/**
		 * sys_business_code_detail表主键
		 */
		private Long id;

		/**
		 * 父级id，0表示顶级
		 */
		private Long parentId;

		@NotBlank(message = "业务取值【value】不能为空")
		private String value;

		@NotBlank(message = "业务取值名称【label】不能为空")
		private String label;

		@NotNull(message = "排序【sort】不能为空")
		private Integer sort;

		/**
		 * 下级
		 */
		private List<SysBusinessCodeDetailVo> children;

	}

}
